// https://www.luogu.com.cn/problem/P3383
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstring>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
int rad();  // read int
const int max_size = 5 + 1e8;
const int maxn = 5 + 1e7;

int n, m;
int tot, pri[maxn];
bool visit[max_size];

void get_prime(int ed) {
    for (int i = 2; i <= ed; ++i) {
        if (!visit[i]) pri[++tot] = i;
        for (int j = 1; j <= tot && pri[j] * i <= ed; ++j) {
            visit[pri[j] * i] = 1;
            if (i % pri[j] == 0) break;
        }
    }
}

int main() {
    n = rad(), m = rad();
    get_prime(n);
    rf(i, m) {
        printf("%d\n", pri[rad()]);
    }
}

int rad() {
    int back = 0, ch = 0, neg = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        neg = ch == '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return (back ^ -neg) + neg;
}